package com.jianzong.lingxuan.admin.service.impl;

import com.jianzong.lingxuan.admin.service.AdminService;
import com.jianzong.lingxuan.api.service.ApiService;
import com.jianzong.lingxuan.api.service.SectUserService;
import com.jianzong.lingxuan.base.Result;
import com.jianzong.lingxuan.enums.AdminEnum;
import com.jianzong.lingxuan.enums.ApiEnum;
import com.jianzong.lingxuan.enums.SysInfo;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @auth Leiwenlong
 * @since 2021/7/19
 *   统一处理类
 */
@Service
public class AdminServiceImpl implements AdminService {

    public final SectUserService sectUserService;

    public AdminServiceImpl(SectUserService sectUserService){
        this.sectUserService = sectUserService;
    }

    @Override
    public Result<?> action(Map<String, String[]> map,String token) {

        if(map.get("action").length< 0){
            return Result.error("");
        }

        String[] actions = map.get("action");
        String action = actions[0];

        switch (AdminEnum.getByName(action)){
            case USERLIST:
                System.out.println("This is USERLIST Action...");
                return sectUserService.userList(map);
            default:
                return Result.error(SysInfo.PARAM_NOTACTION);
        }

    }

}
